package servlets;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created with IntelliJ IDEA.
 * User: zhanna_mukanova
 * Date: 9/11/13
 * Time: 10:48 AM
 * To change this template use File | Settings | File Templates.
 */
@WebServlet("/s")
public class MyServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String title = "Simple Servlet Output";
        // сначала установите тип содержания и другие поля заголовков ответа
        response.setContentType("text/html");
        out.println("<HTML><HEAD><TITLE>");
        out.println(title);
        out.println("</TITLE></HEAD><BODY>");
        out.println("<H1>" + title + "</H1>");
        out.print("<P>This is ");
        out.print(this.getClass().getName());
        out.print(", using the GET method");
        out.println("</BODY></HTML>");
        out.close();

    }
}
